/*
 * @Description: 订单事件的处理
 * @Author: GGB
 * @Date: 2021-12-27 09:34:45
 * @LastEditors: GGB
 * @LastEditTime: 2022-02-23 16:45:26
 */

import {
  UpdatePriceType,
  DeliveryType,
  ConfirmCancelType,
  ApplyCancelType,
  VerifyType,
  OrderVerifyType,
  ReceiptType,
} from './model/orderModel';
import { defHttp } from '/@/utils/http/axios';

import { BasicResult } from '../model/baseModel';

enum Api {
  Delivery = '/order.event/delivery',
  UpdatePrice = '/order.event/updatePrice',
  ConfirmCancel = '/order.event/confirmCancel',
  OrderVerify = '/order.event/orderVerify',
  Verify = '/order.event/verify',
  ApplyCancel = '/order.event/applyCancel',
  Receipt = '/order.event/receipt',
  UpdatePrint='/order.event/updatePrint'
}

/**
 * 订单确认收货
 * @param {*} data { orderId }
 * @returns
 */
export const confirmReceiptAction = (data: ReceiptType) =>
  defHttp.post<BasicResult>({ url: Api.Receipt, data });

/**
 * 申请取消订单
 * @param {*} data { orderId }
 * @returns
 */
export const applyCancel = (data: ApplyCancelType) =>
  defHttp.post<BasicResult>({ url: Api.ApplyCancel, data });

/**
 * 后台通过订单ID一键核验
 * @returns {*} data :{ orderId }
 */
export const orderVerify = (data: OrderVerifyType) =>
  defHttp.post<BasicResult>({ url: Api.OrderVerify, data });
/**
 * 后台通过核验码核验
 * @returns {*} data :{ verifyCode }
 */
export const overifyByCode = (data: VerifyType) =>
  defHttp.post<BasicResult>({ url: Api.Verify, data });

/**
 * 确认发货
 * @param {*} data
 */
export const delivery = (data: DeliveryType) =>
  defHttp.post<BasicResult>({ url: Api.Delivery, data });

/**
 * 修改订单价格
 * @param {*} data
 */
export const updatePrice = (data: UpdatePriceType) =>
  defHttp.post<BasicResult>({ url: Api.UpdatePrice, data });

/**
 * 审核：用户取消订单
 * @param {*} data
 */
export const confirmCancel = (data: ConfirmCancelType) =>
  defHttp.post<BasicResult>({ url: Api.ConfirmCancel, data });

  /**
 * 审核：用户取消订单
 * @param {*} data
 */
export const updatePrint = (data: ReceiptType) =>
defHttp.post<BasicResult>({ url: Api.UpdatePrint, data });
